import { getBaseResourceByDirection } from "@/api/resource";
import { refactoringArr} from "@/util/common";

const resource = {
  state: {
    resourceDataList:[],
  },
  mutations: {
    SET_RESOURCEDATASLIST: (state, data) => {
      state.resourceDataList = data;
    }
  },
  actions: {
    // 根据方向获取权限资源
    getBaseResourceListByDirection({state,commit },params) {
      return new Promise(resolve => {
        getBaseResourceByDirection(
         params
            ).then(res => {
              let resultArr= refactoringArr(
                res.data,
                "",
                0,
                "disableCheckbox",
                "scopedSlots"
              );
              commit("SET_RESOURCEDATASLIST",resultArr );
              resolve(resultArr);
          });
      });
    }
  }
};

export default resource;
